import 'package:flutter/material.dart';

/// @date 2020/08/11  16:36
/// @author 程志强
/// @des

class HeroRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("Hero动画"),
        ),
        body: Container(
          alignment: Alignment.center,
          child: InkWell(
            child: Hero(
              // 唯一标记，前后两个路由页Hero的tag必须相同
              tag: "avatar",
              child: ClipOval(
                  child: Image.network(
                "https://bkimg.cdn.bcebos.com/pic/023b5bb5c9ea15ceba721521ba003af33a87b27e?x-bce-process=image/resize,m_lfit,w_268,limit_1/format,f_jpg",
                width: 50,
              )),
            ),
            onTap: () {
              Navigator.push(context, PageRouteBuilder(pageBuilder:
                  (BuildContext context, Animation animation,
                      Animation secondaryAnimation) {
                return new FadeTransition(
                    opacity: animation,
                    child: Scaffold(
                      appBar: AppBar(
                        title: Text("原图"),
                      ),
                      body: HeroAnimationRouteB(),
                    ));
              }));
            },
          ),
        ));
  }
}

class HeroAnimationRouteB extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Hero(
        tag: "avatar", //唯一标记，前后两个路由页Hero的tag必须相同
        child: Image.network("https://bkimg.cdn.bcebos.com/pic/023b5bb5c9ea15ceba721521ba003af33a87b27e?x-bce-process=image/resize,m_lfit,w_268,limit_1/format,f_jpg",),
      ),
    );
  }
}
